package com.jiaai.cloud.wx.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 生活圈信息表
 * </p>
 *
 * @author 佳爱网络科技
 * @since 2017-09-26
 */
@TableName("t_lifecycle")
public class TLifecycle extends Model<TLifecycle> {

    private static final long serialVersionUID = 1L;

    /**
     * 商店id
     */
	private Integer shopid;
    /**
     * id
     */
	@TableId(value="lc_id", type= IdType.AUTO)
	private Integer lcId;
    /**
     * 生活圈标题
     */
	@TableField("lc_titile")
	private String lcTitile;
    /**
     * 文章简介
     */
	@TableField("lc_abstract")
	private String lcAbstract;
    /**
     * 文章内容
     */
	@TableField("lc_content")
	private String lcContent;
    /**
     * 文章的图片, 逗号隔开
     */
	@TableField("lc_pics")
	@JSONField(serialize = false)
	private String lcPics;


	public Integer getShopid() {
		return shopid;
	}

	public void setShopid(Integer shopid) {
		this.shopid = shopid;
	}

	public Integer getLcId() {
		return lcId;
	}

	public void setLcId(Integer lcId) {
		this.lcId = lcId;
	}

	public String getLcTitile() {
		return lcTitile;
	}

	public void setLcTitile(String lcTitile) {
		this.lcTitile = lcTitile;
	}

	public String getLcAbstract() {
		return lcAbstract;
	}

	public void setLcAbstract(String lcAbstract) {
		this.lcAbstract = lcAbstract;
	}

	public String getLcContent() {
		return lcContent;
	}

	public void setLcContent(String lcContent) {
		this.lcContent = lcContent;
	}

	public String getLcPics() {
		return lcPics;
	}

	public void setLcPics(String lcPics) {
		this.lcPics = lcPics;
	}

	@Override
	protected Serializable pkVal() {
		return this.lcId;
	}

	/**
	 * 图片数组
	 */
	@TableField(exist = false)
	private List<String> Pics = new ArrayList<>();

	public List<String> getPics() {
		if (StringUtils.isEmpty(lcPics)){
			return null;
		}
		if (lcPics.indexOf(",") == -1){
			Pics.add(lcPics);
		} else {
			Pics = Arrays.asList(lcPics.split(","));
		}
		return Pics;
	}

	public void setPics(List<String> pics) {
		Pics = pics;
	}
}
